#ifndef __PARSERGLOBALS_H__
#define __PARSERGLOBALS_H__

static QString H_RAPIDSHARE = "\"http://rapidshare.com*\"";
static QString H_UPLOADJOCKEY  = "\"http://www.uploadjockey.com/*\"";
static QString H_UJRAPIDLINK = "<a href=\"http://www.uploadjockey.com/redirect.php?url=*>Rapidshare.com</a>";

#include <QRegExp>
#include <QDebug>
#include <QString>

bool parseUploadjockeyResult( const QString& desc, QString& result)
{
	int ind = 0, offset = 0, of2 = 0;
	QRegExp rxRapid( H_UJRAPIDLINK );
	rxRapid.setPatternSyntax(QRegExp::Wildcard);
	rxRapid.setMinimal( true );	
	ind = rxRapid.indexIn(desc);
	if( ind != -1 )
	{
		offset = rxRapid.matchedLength();
		if( offset != -1 )
		{
			result = desc.mid( ind+1, offset );
			offset = result.lastIndexOf( "http" );			
			of2 = result.indexOf("\"", offset);
			result = result.mid( offset, of2 - offset );
			qDebug() << result;
			return true;
		}
	}
	return false;
}

bool rapidshareLink( const QString& desc, QString& result )
{
	int ind = 0, offset = 0;
	QRegExp rxRapid( H_RAPIDSHARE );
	rxRapid.setPatternSyntax(QRegExp::Wildcard);
	rxRapid.setMinimal( true );
	ind = rxRapid.indexIn(desc);
	if( ind != -1 )
	{
		offset = rxRapid.matchedLength();
		if( offset != -1 )
		{
			result = desc.mid( ind+1,offset-2);
			qDebug() << result;
			return true;
		}
	}
	return false;
}

bool uploadJockey( const QString& desc, QString& result )
{
	int ind = 0, offset = 0;
	QRegExp rx( H_UPLOADJOCKEY );
	rx.setPatternSyntax(QRegExp::Wildcard);
	rx.setMinimal( true );
	ind = rx.indexIn(desc);
	if( ind != -1 )
	{
		offset = rx.matchedLength();
		if( offset != -1 )
		{
			result = desc.mid( ind + 1 ,offset - 2);
			qDebug() << result;
			return true;
		}
	}
	return false;
}
#endif //__PARSERGLOBALS_H__
//eof
